package com.mmall.common;


import java.util.Scanner;

public class test {
    public static void main(String[] args){
        TestThread t = new TestThread();
        new Thread(t,"1").start();
        new Thread(t,"2").start();
        new Thread(t,"3").start();
        new Thread(t,"4").start();
    }
}
class TestThread extends Thread{

    private static  int tickets = 200;
    public void run(){
            sale();
    }
    public synchronized static void sale(){
        while(tickets > 0){
           System.out.println(Thread.currentThread().getName()
                   + " is salling ticket " + tickets--);
           try{
               Thread.sleep(10);
           }
           catch(Exception e){
               System.out.println(e.getMessage());
           }
        }
    }

}
